package com.ruoyi.constituent.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SNUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.constituent.mapper.ConstituentDataMapper;
import com.ruoyi.constituent.domain.ConstituentData;
import com.ruoyi.constituent.service.IConstituentDataService;

/**
 * 成分Service业务层处理
 * 
 * @author weihanqiang
 * @date 2025-04-30
 */
@Service
public class ConstituentDataServiceImpl implements IConstituentDataService 
{
    @Autowired
    private ConstituentDataMapper constituentDataMapper;

    @Autowired
    private SNUtil snUtil;
    /**
     * 查询成分
     * 
     * @param constituentId 成分主键
     * @return 成分
     */
    @Override
    public ConstituentData selectConstituentDataByConstituentId(Long constituentId)
    {
        return constituentDataMapper.selectConstituentDataByConstituentId(constituentId);
    }

    /**
     * 查询成分列表
     * 
     * @param constituentData 成分
     * @return 成分
     */
    @Override
    public List<ConstituentData> selectConstituentDataList(ConstituentData constituentData)
    {
        return constituentDataMapper.selectConstituentDataList(constituentData);
    }

    /**
     * 新增成分
     * 
     * @param constituentData 成分
     * @return 结果
     */
    @Override
    public int insertConstituentData(ConstituentData constituentData)
    {
        String constituent_no = snUtil.generateSN("constituent_data", "constituent_no", "yyyyMMdd", "CON", 4);
        constituentData.setConstituentNo(constituent_no);
        constituentData.setCreateTime(DateUtils.getNowDate());
        constituentData.setCreateTime(DateUtils.getNowDate());
        return constituentDataMapper.insertConstituentData(constituentData);
    }

    /**
     * 修改成分
     * 
     * @param constituentData 成分
     * @return 结果
     */
    @Override
    public int updateConstituentData(ConstituentData constituentData)
    {
        return constituentDataMapper.updateConstituentData(constituentData);
    }

    /**
     * 批量删除成分
     * 
     * @param constituentIds 需要删除的成分主键
     * @return 结果
     */
    @Override
    public int deleteConstituentDataByConstituentIds(Long[] constituentIds)
    {
        return constituentDataMapper.deleteConstituentDataByConstituentIds(constituentIds);
    }

    /**
     * 删除成分信息
     * 
     * @param constituentId 成分主键
     * @return 结果
     */
    @Override
    public int deleteConstituentDataByConstituentId(Long constituentId)
    {
        return constituentDataMapper.deleteConstituentDataByConstituentId(constituentId);
    }
}
